package com.controller.dashboard;

import com.model.pojo.RepEntity;
import com.model.pojo.TestPage;
import com.model.pojo.annotation.CheckToken;
import com.model.vo.configVo.ChangeOrderInfo;
import com.model.vo.configVo.ChartsToDashInfo;
import com.model.vo.configVo.DashboardsInfo;
import com.server.dashboard.DashboardsService;
import com.server.dashboard.DashboardsToChartsUtilService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.sql.SQLException;
import java.util.List;

@RestController
public class DashboardsController {
    @Autowired
    DashboardsService dashboardsService;
    @Autowired
    DashboardsToChartsUtilService dashboardsToChartsUtilService;

    /*
    保存看板
     */
    @CheckToken
    @RequestMapping("/inputDashboards")
    public RepEntity inputDashboards(@RequestHeader String token, @RequestBody DashboardsInfo body){
        return dashboardsService.setDashboards(token, body);
    }

    /*
    更新看板
     */
    @CheckToken
    @RequestMapping("/updateDashboards")
    public RepEntity updateDashboards(@RequestHeader String token,@RequestBody DashboardsInfo body){
        return dashboardsService.updateDashboards(token, body);
    }
    /*
    删除看板
     */
    @CheckToken
    @RequestMapping("/delDashboards")
    public RepEntity delDashboards(@RequestHeader String token,@RequestBody List<Integer> body){
        return dashboardsService.delDashboards(token, body);
    }

    /*
    查看列表
     */
    @CheckToken
    @RequestMapping("/getListDashboards")
    public RepEntity getListDashboards(@RequestHeader String token, @RequestBody TestPage body){
        return dashboardsService.getListDashboards(token, body);
    }

    /*
    查看单个看板
     */
    @CheckToken
    @RequestMapping("/getDashboards")
    public RepEntity getDashboards(@RequestHeader String token,@RequestBody int body){
        return dashboardsService.getDashboards(token, body);
    }

    /*
    转交看板
     */
    @CheckToken
    @RequestMapping("/changeDashOrder")
    public RepEntity changeDashOrder(@RequestHeader String token,@RequestBody ChangeOrderInfo body){
        return dashboardsService.changeDashOrder(token, body);
    }

    /*
    查看看板分发列表
     */
    @CheckToken
    @RequestMapping("/getDashOrder")
    public RepEntity getDashOrder(@RequestHeader String token,@RequestBody int body){
        return dashboardsService.getDashOrder(token, body);
    }

    /*
    看板生成图表
     */
    @RequestMapping("/showChartsInDash")
    public RepEntity showChartsInDash(@RequestHeader String token, @RequestBody ChartsToDashInfo body) throws SQLException {
        return dashboardsToChartsUtilService.getChartsInDash(body, token);
    }
}
